﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using Honestysoft.BaseObject;
using Honestysoft.DictionaryHelper;
using System.Text;

namespace Honestysoft.Financing.WebUI.Module.Reports.JSON
{
    /// <summary>
    /// GetProjectCategory 的摘要说明
    /// </summary>
    public class GetProjectCategory : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            List<Sys_Dictionary> lsDict = Honestysoft.DictionaryHelper.DictionaryInstance.GetDictionaryList("ProjectCategory");
            string responseData = "";
            if (lsDict != null && lsDict.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("[");
                foreach (Sys_Dictionary dict in lsDict)
                {
                    sb.Append("{");
                    sb.Append("\"id\":");
                    sb.AppendFormat("\"{0}\",", dict.DictValue);
                    sb.Append("\"text\":");
                    sb.AppendFormat("\"{0}\"", dict.DictName);
                    sb.Append("},");
                }
                sb.Remove(sb.Length - 1, 1);
                sb.Append("]");
                responseData = sb.ToString();
            }
            context.Response.Write(responseData);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}